package com.fare.taluo.fetl.domain.entity;

import java.util.Date;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;

import com.dayatang.domain.InstanceFactory;
import com.fare.taluo.fetl.domain.base.BaseFetlEntity;
import com.fare.taluo.fetl.domain.repository.IFreightMontorRepository;
import com.fare.taluo.fetl.domain.repository.IFreightPriceRepository;

/**
 * 
 * @author 416428406@qq.com
 * @since 2013/09/04
 */
@Entity
@Table(name = "freight_price")
public class FreightPriceEntity extends BaseFetlEntity {
	/**
	 * 
	 */
	private static final long serialVersionUID = 7146835608410264975L;
	/*
	 * @Id
	 * 
	 * @Column(name = "ID", length = 32)
	 * 
	 * @GeneratedValue(strategy = GenerationType.AUTO) private String id;
	 * 
	 * @Column(name = "fromCity") private String fromCity;
	 * 
	 * @Column(name = "toCity") private String toCity;
	 * 
	 * @Column(name = "fromCityName") private String fromCityName;
	 * 
	 * @Column(name = "toCityName") private String toCityName;
	 * 
	 * @Column(name = "grabChannel") private String grabChannel;
	 * 
	 * @Column(name = "grabChannelKey") private String grabChannelKey;
	 * 
	 * @Column(name = "price") private Double price;
	 * 
	 * @Column(name = "CompareGrabChannel") private String compareGrabChannel;
	 * 
	 * @Column(name = "CompareGrabChannelKey") private String
	 * compareGrabChannelKey;
	 * 
	 * @Column(name = "ComparePrice") private String comparePrice;
	 * 
	 * @Column(name = "flightNo") private String flightNo;
	 * 
	 * @Column(name = "grabDate") private Date grabDate;
	 * 
	 * @Column(name = "priceRatio") private Double priceRatio;
	 * 
	 * @Column(name = "flightDate") private Date flightDate;
	 */
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	private Integer id;
	@Column
	private String rowkey;
	@Column
	private String fromCity;
	@Column
	private String fromCityName;
	@Column
	private String toCity;
	@Column
	private String toCityName;
	@Column
	private String grabChannel;
	@Column
	private String grabChannelKey;
	@Column
	private Double price;
	@Column
	private String cabinLevel;
	@Column
	private String compareCabinLevel;
	@Column
	private String compareGrabChannel;
	@Column
	private String compareGrabChannelKey;
	@Column
	private Double comparePrice;
	@Column
	private String flightNo;
	@Column
	private String compareFlightNo;
	@Column
	private Date grabDate;
	@Column
	private Date flightDate;
	@Column
	private Double priceRatio;

//	private static IFreightPriceRepository freightPriceRepository = InstanceFactory
//			.getInstance(IFreightPriceRepository.class);
	private static IFreightPriceRepository getIFreightPriceRepository(){
		return InstanceFactory
				.getInstance(IFreightPriceRepository.class);
	}
	public List<FreightPriceEntity> findByConditionSpread(String fromCity,
			String toCity, String grabChannelKey, String flightNo,
			Date flightDate, String compareGrabChannelKey, Date createTime,Integer continueDays) {
		return getIFreightPriceRepository().findByConditionSpread(fromCity, toCity,
				grabChannelKey, flightNo, flightDate, compareGrabChannelKey,
				createTime, continueDays);
	}
	public List<FreightPriceEntity> findByConditionContrast(String fromCity,String toCity,String grabChannelKey,String flightNo,Date flightDate,String cabinLevel,String contrastCompanyKey,String contrastFlightNo,String contrastCabinLevel,Date createTime ,Integer continueDays){
		return getIFreightPriceRepository().findByConditionContrast(fromCity, toCity, grabChannelKey, flightNo, flightDate, cabinLevel, contrastCompanyKey, contrastFlightNo, contrastCabinLevel, createTime, continueDays);
	}
	public String getFromCity() {
		return fromCity;
	}

	public void setFromCity(String fromCity) {
		this.fromCity = fromCity;
	}

	public String getToCity() {
		return toCity;
	}

	public void setToCity(String toCity) {
		this.toCity = toCity;
	}

	public String getFromCityName() {
		return fromCityName;
	}

	public void setFromCityName(String fromCityName) {
		this.fromCityName = fromCityName;
	}

	public String getToCityName() {
		return toCityName;
	}

	public void setToCityName(String toCityName) {
		this.toCityName = toCityName;
	}

	public String getGrabChannel() {
		return grabChannel;
	}

	public void setGrabChannel(String grabChannel) {
		this.grabChannel = grabChannel;
	}

	public String getGrabChannelKey() {
		return grabChannelKey;
	}

	public void setGrabChannelKey(String grabChannelKey) {
		this.grabChannelKey = grabChannelKey;
	}

	public Double getPrice() {
		return price;
	}

	public void setPrice(Double price) {
		this.price = price;
	}

	public String getCompareGrabChannel() {
		return compareGrabChannel;
	}

	public void setCompareGrabChannel(String compareGrabChannel) {
		this.compareGrabChannel = compareGrabChannel;
	}

	public String getCompareGrabChannelKey() {
		return compareGrabChannelKey;
	}

	public void setCompareGrabChannelKey(String compareGrabChannelKey) {
		this.compareGrabChannelKey = compareGrabChannelKey;
	}

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getRowkey() {
		return rowkey;
	}

	public void setRowkey(String rowkey) {
		this.rowkey = rowkey;
	}

	public String getCabinLevel() {
		return cabinLevel;
	}

	public void setCabinLevel(String cabinLevel) {
		this.cabinLevel = cabinLevel;
	}

	public String getCompareCabinLevel() {
		return compareCabinLevel;
	}

	public void setCompareCabinLevel(String compareCabinLevel) {
		this.compareCabinLevel = compareCabinLevel;
	}

	public Double getComparePrice() {
		return comparePrice;
	}

	public void setComparePrice(Double comparePrice) {
		this.comparePrice = comparePrice;
	}

	public String getCompareFlightNo() {
		return compareFlightNo;
	}

	public void setCompareFlightNo(String compareFlightNo) {
		this.compareFlightNo = compareFlightNo;
	}

	public String getFlightNo() {
		return flightNo;
	}

	public void setFlightNo(String flightNo) {
		this.flightNo = flightNo;
	}

	public Date getGrabDate() {
		return grabDate;
	}

	public void setGrabDate(Date grabDate) {
		this.grabDate = grabDate;
	}

	public Double getPriceRatio() {
		return priceRatio;
	}

	public void setPriceRatio(Double priceRatio) {
		this.priceRatio = priceRatio;
	}

	public Date getFlightDate() {
		return flightDate;
	}

	public void setFlightDate(Date flightDate) {
		this.flightDate = flightDate;
	}
	
	@Override
	public boolean isNew() {
		return getId() == null ;
	}

	@Override
	public boolean existed() {
		if (isNew()) {
			return false;
		}
		return getBaseEntityRepository().exists(getClass(), getId());
	}

	@Override
	public boolean notExisted() {
		return ! existed();
	}
	
	@Override
	public boolean existed(String propertyName, Object propertyValue) {
		// TODO Auto-generated method stub
		return false;
	}

}
